package com.tanhua.model.vo;

import com.tanhua.model.mongo.SoulReport;
import com.tanhua.model.pojo.Dimensions;
import com.tanhua.model.pojo.SimilarYou;
import com.tanhua.model.pojo.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SoulReportVo implements Serializable {
    private String conclusion;  //鉴定结果
    private String cover;       //鉴定图片
    private List<Dimensions> dimensions;  //维度(key:维度项  value:维度值)
    private List<SimilarYou> similarYou;

    public static SoulReportVo init(List<UserInfo> userInfos, SoulReport soulReport) {
        SoulReportVo vo = new SoulReportVo();
        BeanUtils.copyProperties(soulReport, vo);
        List<SimilarYou> SimVos = new ArrayList<>();
        for (UserInfo userInfo : userInfos) {
            SimilarYou similarYou = new SimilarYou();
            similarYou.setId(userInfo.getId());
            if (!StringUtils.isEmpty(userInfo.getAvatar())) {
                similarYou.setAvatar(userInfo.getAvatar());
            }
            SimVos.add(similarYou);
        }
        vo.setSimilarYou(SimVos);
        return vo;
    }
}
